TreeView Control - Expanding Items

Expanding Items

If you want to make sure a node is visible, you can use the EnsureVisible method:

TreeView1.Nodes(21).EnsureVisible

This will expand any items, and scroll as required to ensure that the item specified is visible.

If a node has child items, a + appears next to it. The user can press this to show the child items. When the user expands an node, the Expand event occurs. Once the node has been expanded, a - appears next to it. When this is pressed, the child items are hidden, and the Collapse event occurs

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.